use threads; 
use Thread::Queue;
$| = 1;
my $DataQueue = Thread::Queue->new; 
$thr = threads->new(sub {
    while ($DataElement = $DataQueue->dequeue) { 
        print "Popped $DataElement off the queue\n";
    } 
});
$DataQueue->enqueue(12); 
$DataQueue->enqueue("A", "B", "C"); 
$DataQueue->enqueue(\$thr); 
sleep 10; 
$DataQueue->enqueue(undef);
$thr->join;
